<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head th:replace="~{commons/commons::head}"/>
<head>
<link rel="stylesheet" type="text/css" th:href="@{/css/login.css}" />
<link rel="stylesheet" type="text/css" th:href="@{/css/index.css}" />
<script th:src="@{/bootstrap3/js/jquery.cookie.js}" type="text/javascript" charset="utf-8"></script>
<script th:src="@{/js/autoLogin.js}" type="text/javascript"></script>
</head>

	<body>
		<!--头部-->
		<header class="header">
			<img th:src="@{/images/index/stumalllogo.png}" alt="" />
			<span class="pull-right"><small>欢迎访问</small><b>电脑商城</b></span>
		</header>
		<!--主体-->
		<div class="container mycontent text-left">
			<!--透明层 -->
			<div class="loginDiv">
				<p>用户登录</p>
				<!--表单开始-->
				<form id="form-login"  class="form-horizontal" role="form">
					<!--用户名-->
					<div class="form-group">
						<label for="username" class="col-md-3 control-label">名字：</label>
						<div class="col-md-8">
							<input name="username" type="text" class="form-control" id="username"  placeholder="请输入用户名">
						</div>
					</div>
					<!--密码-->
					<div class="form-group">
						<label for="password" class="col-md-3 control-label"> 密码：</label>
						<div class="col-md-8">
							<input name="password" type="text" class="form-control" id="password"  placeholder="请输入密码">
						</div>
						<!-- 消息提示 -->
					</div>
					<!-- 记住我-->
					<div class="form-group">
						<div class="col-md-offset-3 col-md-6">
							<div class="checkbox">
								<label>
									<input type="checkbox" id="auto" name="auto">自动登录
								</label>
							</div>
						</div>
					</div>
					<!--提交按钮-->
					<div class="form-group">
						<label class="col-md-3 control-label"></label>
						<div class="col-md-8">
							<input id="btn-login" class="btn btn-primary" type="button" value="登录" />
							<span class="pull-right"><small>还没有账号？</small><a th:href="@{/toRegister}">注册</a></span>
						</div>
					</div>
				</form>
			</div>
		</div>
	<div th:replace="~{commons/commons::footer}"/>
		<script type="text/javascript">
			$("#btn-login").click(function() {
				$.ajax({
					url: "/user/toLogin",
					type: "POST",
					data: $("#form-login").serialize(),
					dataType: "json",
					success: function(data) {
						if (data.code == 200) {
							alert("登录成功！");
							location.href = "/toIndex";
						} else {
							alert("登录失败！" + data.msg);
						}
					}
				});
			});
		</script>
	</body>
</html>